/**
 * Created by DELL on 2016/6/23.
 */
//var to_top = '<div class="to-top"><img src="../img/fanhuidingbu.jpg" alt=""/></div>';
//$('body').append(to_top);
$('.to-top').live('click',function(){
    $('body,html').animate({scrollTop:0});
});
$(window).scroll(function(){
    var win_height = $(this).height()*1.5;
    var doc_height = $(window).scrollTop();
    if(doc_height>win_height){
        $('.share').fadeIn();
    }else{
        $('.share').fadeOut();
    }
});

/**
 * js动态添加css,js文件
 */
var dynamicLoading = {
    css: function(path){
        if(!path || path.length === 0){
            throw new Error('argument "path" is required !');
        }
        var head = document.getElementsByTagName('head')[0];
        var link = document.createElement('link');
        link.href = path;
        link.rel = 'stylesheet';
        link.type = 'text/css';
        head.appendChild(link);
    },
    js: function(path){
        if(!path || path.length === 0){
            throw new Error('argument "path" is required !');
        }
        var head = document.getElementsByTagName('head')[0];
        var script = document.createElement('script');
        script.src = path;
        script.type = 'text/javascript';
        head.appendChild(script);
    }
};
dynamicLoading.js("../js/date.js");